// index.js
const defaultAvatarUrl = 'https://mmbiz.qpic.cn/mmbiz/icTdbqWNOwNRna42FI242Lcia07jQodd2FJGIYQfG0LAJGFxM4FbnQP6yfMxBgJ0F3YRqJCJ1aPAK2dQagdusBZg/0'
const _function = require("../../utils/functionData.js")
Page({
  data: {
    isModalShow: false, // 控制弹出层显示
    input1: "", // 输入框1的值
    input2: "", // 输入框2的值
    carInfo: {}
  },
  onLoad() {
    this.getCarInfo()
  },
  onShow() {
    this.getCarInfo()
  },
  getCarInfo(e) {
    const param = {
    }
    _function.getCarInfo(param, this.getCarInfoBack, this)
  },
  getCarInfoBack(res) {
    let dataAll = res.data

    if (dataAll.isSuccess == true) {
      dataAll.property.msg = dataAll.property.msg.split('|')
      this.setData({
        carInfo: dataAll.property
      })
      console.log(123123, this.data);
      wx.showToast({
        title: dataAll.msg,
        icon: 'none',
        duration: 1500,
        mask: true,
        success: () => {
        }
      });
    }
  },
  // 显示弹出层
  showModal() {
    this.setData({ isModalShow: true });
  },

  onInput1(e) {
    this.setData({ input1: e.detail.value });
  },

  onInput2(e) {
    this.setData({ input2: e.detail.value });
  },

  sendForm() {
    const { input1, input2 } = this.data;
    console.log("输入框1的值：", input1);
    console.log("输入框2的值：", input2);
    const param = {
      input1, input1
    }
    _function.sendCarInfo(param, this.sendCarInfoBack, this)
 
  },

  sendCarInfoBack(res) {
    let dataAll = res.data
    if (dataAll.isSuccess == true) {
      this.closeModal();
      wx.showToast({
        title: "表单已发送",
        icon: "success",
        duration: 2000,
      });
    }
  },
  closeModal() {
    this.setData({ isModalShow: false });
  },
  preventD() {
    // 空函数，用于阻止 touchmove 事件冒泡
  },
  stopPropagation(e) {
    console.log(e);
    e.stopPropagation(); // 阻止事件冒泡，避免点击内容区域关闭弹出层
  },
  goSearch(){
    wx.navigateTo({
      url: '/pages/searchInfo/index',
    })
  }
})
